<?php
header("Content-type:text/html; charset=UTF-8");



function taobao_item_get($num_iid){

$Taoapi_Config = Taoapi_Config::Init();
$Taoapi_Config->setCharset('UTF-8');

$Taoapi = new Taoapi;

$Taoapi->method = 'taobao.item.get';

$Taoapi->fields = 'num_iid,props_name,cid,pic_url,price,wap_desc,title,props,template_id,after_sale_id,inner_shop_auction_tem,outer_shop_auction_te,outer_id,nick,postage_id,type';

$Taoapi->num_iid = $num_iid;

$TaobaokeData = $Taoapi->Send('get','xml')->getArrayData();

$taobaokeItem = $TaobaokeData['posters']['poster'];
	return $TaobaokeData;
}


function taobao_itemprops_get($cid,$pid='',$child_path='',$parent_pid=''){

$Taoapi_Config = Taoapi_Config::Init();
$Taoapi_Config->setCharset('UTF-8');

$Taoapi = new Taoapi;

$Taoapi->method = 'taobao.itemprops.get';

$Taoapi->fields = 'pid,name,must,multi,prop_values';

$Taoapi->cid = $cid;
$Taoapi->pid = $pid;
$Taoapi->child_path = $child_path;
$Taoapi->parent_pid = $parent_pid;


$TaobaokeData = $Taoapi->Send('get','xml')->getArrayData();



return $TaobaokeData;



}


function taobao_itemcats_get($cids,$parent_cid=''){
	//获取后台供卖家发布商品的标准商品类目

$Taoapi_Config = Taoapi_Config::Init();
$Taoapi_Config->setCharset('UTF-8');

$Taoapi = new Taoapi;

$Taoapi->method = 'taobao.itemcats.get';

$Taoapi->fields = 'cid,parent_cid,name,is_parent,status';

$Taoapi->parent_cid = $parent_cid;
$Taoapi->cids = $cids;





$TaobaokeData = $Taoapi->Send('get','xml')->getArrayData();
$taobaokeItem = $TaobaokeData['posters']['poster'];
	return $TaobaokeData;
}




function taobao_items_search($cid,$nicks,$page_no=''){
	//搜索商品信息
echo $nicks;
$Taoapi_Config = Taoapi_Config::Init();
$Taoapi_Config->setCharset('UTF-8');

$Taoapi = new Taoapi;

$Taoapi->method = 'taobao.items.search';

$Taoapi->fields = 'iid,title,nick,pic_url,cid,price,type,delist_time,post_fee,num_iid';
$Taoapi->cid = $cid;
//$Taoapi->props=$props;
$Taoapi->start_score='5';
//$Taoapi->is_mall =$is_mall;
$Taoapi->page_no = $page_no;
 $Taoapi->nicks = $nick;
 $Taoapi->order_by = 'volume:desc';
//$Taoapi->parent_cid = $parent_cid;
$Taoapi->cids = $cids;
$TaobaokeData = $Taoapi->Send('get','xml')->getArrayData();
$taobaokeItem = $TaobaokeData['posters']['poster'];
	return $TaobaokeData;
}

function taobao_taobaoke_caturl_get($cid){
	//搜索商品信息

$Taoapi_Config = Taoapi_Config::Init();
$Taoapi_Config->setCharset('UTF-8');

$Taoapi = new Taoapi;

$Taoapi->method = 'taobao.taobaoke.caturl.get';

$Taoapi->fields = 'iid,title,nick,pic_url,cid,price,type,delist_time,post_fee';
$Taoapi->cid = $cid;

$Taoapi->nick ='tx1860';


$TaobaokeData = $Taoapi->Send('get','xml')->getArrayData();
$taobaokeItem = $TaobaokeData['posters']['poster'];
	return $TaobaokeData;
}


function taobao_itempropvalues_get($cid,$pvs){
	//搜索商品信息

$Taoapi_Config = Taoapi_Config::Init();
$Taoapi_Config->setCharset('UTF-8');

$Taoapi = new Taoapi;

$Taoapi->method = 'taobao.itempropvalues.get';

$Taoapi->fields = 'cid,pid,prop_name,vid,name,name_alias,status,sort_orde';
$Taoapi->cid = $cid;

$Taoapi->pvs = $pvs;


$TaobaokeData = $Taoapi->Send('get','xml')->getArrayData();
$taobaokeItem = $TaobaokeData['posters']['poster'];
return $TaobaokeData;
}



function taobao_taobaoke_items_detail_get($num_iids){
	//搜索商品信息

$Taoapi_Config = Taoapi_Config::Init();
$Taoapi_Config->setCharset('UTF-8');

$Taoapi = new Taoapi;

$Taoapi->method = 'taobao.taobaoke.items.detail.get';

$Taoapi->fields = 'num_iid,detail_url,click_url,title';
$Taoapi->num_iids = $num_iids;
$Taoapi->nick = 'tx1860';



$TaobaokeData = $Taoapi->Send('get','xml')->getArrayData();

return $TaobaokeData;
}



function taobao_taobaoke_listurl_get($num_iids){
	//搜索商品信息

$Taoapi_Config = Taoapi_Config::Init();
$Taoapi_Config->setCharset('UTF-8');

$Taoapi = new Taoapi;

$Taoapi->method = 'taobao.taobaoke.listurl.get';


$Taoapi->q = $num_iids;
$Taoapi->nick = 'tx1860';



$TaobaokeData = $Taoapi->Send('get','xml')->getArrayData();

return $TaobaokeData;
}


function taobao_taobaoke_items_get($keywords,$cid='',$page_no='',$px='commissionNum_desc',$page_size='40'){
	//搜索商品信息

$Taoapi_Config = Taoapi_Config::Init();
$Taoapi_Config->setCharset('UTF-8');

$Taoapi = new Taoapi;


//查询淘宝客推广商品(taobao.taobaoke.items.get)
$Taoapi->method = 'taobao.taobaoke.items.get';
$Taoapi->fields = 'num_iid,iid,title,nick,pic_url,price,click_url,commission,commission_rate,commission_num,commission_volume,seller_credit_score,item_location,shop_click_url';
$Taoapi->nick = 'tx1860';
$Taoapi->keyword = $keywords;
$Taoapi->cid = $cid;
$Taoapi->page_no = $page_no;
		$Taoapi->start_price = 0;
		$Taoapi->end_price = 20000;
		$Taoapi->start_credit = '1diamond';
		$Taoapi->end_credit = '5goldencrown';
		$Taoapi->start_commissionRate = '1';
		$Taoapi->start_commissionNum = '50';
$Taoapi->page_size = $page_size;
$Taoapi->start_credit = '3heart';
$Taoapi->end_credit = '5goldencrown';
$Taoapi->sort = $px;
$TaobaokeData = $Taoapi->Send('get','xml')->getArrayData();

if($TaobaokeData[total_results]==1){
$TaobaokeData2=$TaobaokeData[taobaoke_items][taobaoke_item];
unset($TaobaokeData[taobaoke_items][taobaoke_item]);
$TaobaokeData[taobaoke_items][taobaoke_item][0]=$TaobaokeData2;
}
return $TaobaokeData;
}
function taobao_taobaoke_items_convert($k){
	//获取卖家店铺的基本信息

$Taoapi_Config = Taoapi_Config::Init();
$Taoapi_Config->setCharset('UTF-8');

$Taoapi = new Taoapi;



$Taoapi->method = 'taobao.taobaoke.items.convert';
$Taoapi->fields = 'num_iid,iid,title,nick,pic_url,price,click_url,commission,commission_rate,commission_num,commission_volume,seller_credit_score,item_location,shop_click_url';
$Taoapi->nick = 'tx1860';
$Taoapi->num_iids = $k;

$TaobaokeData = $Taoapi->Send('get','xml')->getArrayData();
return $TaobaokeData;
}



function taobao_taobaoke_shops_convert($k){
	//获取卖家店铺的基本信息

$Taoapi_Config = Taoapi_Config::Init();
$Taoapi_Config->setCharset('UTF-8');

$Taoapi = new Taoapi;



$Taoapi->method = 'taobao.taobaoke.shops.convert';
$Taoapi->fields = 'user_id,shop_title,click_url,commission_rate,shop_type';

$Taoapi->seller_nicks = $k;

$TaobaokeData = $Taoapi->Send('get','xml')->getArrayData();
return $TaobaokeData;
}



function taobao_user_get($k){
	//获取卖家店铺的基本信息



$Taoapi_Config = Taoapi_Config::Init();
$Taoapi_Config->setCharset('UTF-8');

$Taoapi = new Taoapi;
$Taoapi->method = 'taobao.user.get'; 
		$Taoapi->fields = 'user_id,nick,seller_credit'; 
		$Taoapi->nick = $taobao_nick;
		$TaoapiResult=$Taoapi->Send('get','xml');


return $TaobaokeData;
}








/////////////////////////
//直通车API
function taobao_simba_insight_wordsbase_get($k){
	//获取卖家店铺的基本信息

$Taoapi_Config = Taoapi_Config::Init();
$Taoapi_Config->setCharset('UTF-8');

$Taoapi = new Taoapi;
$Taoapi->nick = '洛诗蕊旗舰店';


$Taoapi->method = 'taobao.simba.insight.wordsbase.get';
$Taoapi->session = '610132253f34dd510aa30b278e0617156953b0ff59feee681107112';

$Taoapi->words = $k;
$Taoapi->time = '3MONTH';
$Taoapi->filter = 'PV,CLICK';
$TaobaokeData = $Taoapi->Send('get','xml')->getArrayData();
return $TaobaokeData;
}
function taobao_traderates_search($tid,$seller_nick){
		$Taoapi_Config = Taoapi_Config::Init();
		$Taoapi_Config->setCharset('UTF-8');

		$Taoapi = new Taoapi;
		$Taoapi->method = 'taobao.traderates.search';

		$Taoapi->seller_nick = $seller_nick;
		$Taoapi->page_no = '1';
		$Taoapi->page_size = '40';
		$Taoapi->num_iid = $tid;
		$TaobaokeData = $Taoapi->Send('get','xml')->getArrayData();
		return $TaobaokeData[trade_rates][trade_rate];	
}


function taobao_taobaoke_shops_get($k)
{
		$Taoapi_Config = Taoapi_Config::Init();
		$Taoapi_Config->setCharset('UTF-8');

		$Taoapi = new Taoapi;
		$Taoapi->method = 'taobao.taobaoke.shops.get';
		$Taoapi->fields ='click_url,shop_title';

		$Taoapi->nick = $k;
		$TaobaokeData = $Taoapi->Send('get','xml')->getArrayData();
		return $TaobaokeData[trade_rates][trade_rate];	
}


function taobao_taobaoke_widget_shops_convert($k)
{
		$Taoapi_Config = Taoapi_Config::Init();
		$Taoapi_Config->setCharset('UTF-8');

		$Taoapi = new Taoapi;
		$Taoapi->method = 'taobao.taobaoke.widget.shops.convert';
		$Taoapi->fields ='user_id,shop_title,click_url,commission_rate';
		$Taoapi->seller_nicks = $k;

		$TaobaokeData = $Taoapi->Send('get','xml')->getArrayData();
		return $TaobaokeData[trade_rates][trade_rate];	
}

function taobao_taobaoke_shops_relate_get($k)
{
		$Taoapi_Config = Taoapi_Config::Init();
		$Taoapi_Config->setCharset('UTF-8');

		$Taoapi = new Taoapi;
		$Taoapi->method = 'taobao.taobaoke.shops.relate.get';
		$Taoapi->fields ='num_iid,click_url,commission,commission_rate,commission_num,commission_volume';
		$Taoapi->relate_type = '4';
		$Taoapi->seller_id = $k;
		

		$TaobaokeData = $Taoapi->Send('get','xml')->getArrayData();
		return $TaobaokeData;	
}


function taobao_products_get($k)
{
		$Taoapi_Config = Taoapi_Config::Init();
		$Taoapi_Config->setCharset('UTF-8');

		$Taoapi = new Taoapi;
		$Taoapi->method = 'taobao.products.get';
		$Taoapi->fields ='num_iid,click_url,commission,commission_rate,commission_num,commission_volume';
		$Taoapi->relate_type = '4';
		$Taoapi->seller_id = $k;
		

		$TaobaokeData = $Taoapi->Send('get','xml')->getArrayData();
		return $TaobaokeData[trade_rates][trade_rate];	
}


function taobao_shop_get($k)
{
		$Taoapi_Config = Taoapi_Config::Init();
		$Taoapi_Config->setCharset('UTF-8');

		$Taoapi = new Taoapi;
		$Taoapi->method = 'taobao.shop.get';
		$Taoapi->fields ='title,desc,bulletin,pic_path,created,shop_score';

		$Taoapi->nick = $k;
		$TaobaokeData = $Taoapi->Send('get','xml')->getArrayData();
		return $TaobaokeData[trade_rates][trade_rate];	
}
















function dangdang_fc($d,$a='3'){
$d = str_replace('画报','',$d);
$so = scws_new();
$so->set_charset('utf8');
// 这里没有调用 set_dict 和 set_rule 系统会自动试调用 ini 中指定路径下的词典和规则文件
$so->send_text($d);


//这里是提取权重最高的前20名，还有其他函数要用去看手册了
$tmp = $so->get_tops('1');


for($i=0; $i<$a; $i++){

    $str .=$tmp[$i]['word']." ";
}
//$str = substr($str, 0, -1);
$str = mb_substr($str, 0, -1, "utf8");

$so->close();


return $str;

	}
function dangdang_tt($fc){	
$a=explode(" ",$fc);
	foreach($a as $id=>$t){
	$b[$id][name]=$t;
	$b[$id][url]=urlencode($t);
	}
return $b;
	}
	
function deletehtml($str,$b=30){
$str = trim($str);
$str=strip_tags($str,"");
$str=preg_replace("{\t}","",$str);
$str=preg_replace("{\r\n}","",$str);
$str=preg_replace("{\r}","",$str);
$str=preg_replace("{\n}","",$str);
$str=preg_replace("{ }","",$str);
return cut_strtt($str,$b,'0','UTF-8') ;
}
function cut_strtt($string, $sublen, $start = 0, $code = 'UTF-8') 
{ 
if($code == 'UTF-8') 
{ 
$pa ="/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|\xe0[\xa0-\xbf][\x80-\xbf]|[\xe1-\xef][\x80-\xbf][\x80-\xbf]|\xf0[\x90-\xbf][\x80-\xbf][\x80-\xbf]|[\xf1-\xf7][\x80-\xbf][\x80-\xbf][\x80-\xbf]/"; 
preg_match_all($pa, $string, $t_string); if(count($t_string[0]) - $start > $sublen) return join('', array_slice($t_string[0], $start, $sublen))."..."; 
return join('', array_slice($t_string[0], $start, $sublen)); 
} 
else 
{ 
$start = $start*2; 
$sublen = $sublen*2; 
$strlen = strlen($string); 
$tmpstr = ''; for($i=0; $i<$strlen; $i++) 
{ 
if($i>=$start && $i<($start+$sublen)) 
{ 
if(ord(substr($string, $i, 1))>129) 
{ 
$tmpstr.= substr($string, $i, 2); 
} 
else 
{ 
$tmpstr.= substr($string, $i, 1); 
} 
} 
if(ord(substr($string, $i, 1))>129) $i++; 
} 
if(strlen($tmpstr)<$strlen ) $tmpstr.= "..."; 
return $tmpstr; 
} 
}
function object_array($array)
{
   if(is_object($array))
   {
    $array = (array)$array;
   }
   if(is_array($array))
   {
    foreach($array as $key=>$value)
    {
     $array[$key] = object_array($value);
    }
   }
   return $array;
}


?>